package com.basic.bio.chat.groupchat;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.Socket;

/**
 * @Description:
 * @Date: 2024-03-28 20:07
 * @Author: wz
 **/
public class ClientReceiveThread extends Thread{

    private Socket socket;

    public ClientReceiveThread(Socket socket) {
        this.socket = socket;
    }

    @Override
    public void run() {
        System.out.println("客户端开始收消息咯。。。");
        try {
//            InputStream is = socket.getInputStream();
//            BufferedReader reader = new BufferedReader(new InputStreamReader(is));
//            System.out.println("服务端发来的消息："+reader.readLine());
            BufferedReader br=new BufferedReader(new InputStreamReader(socket.getInputStream()));
            String line = null;
            while ((line=br.readLine())!=null){
                System.out.println("服务端发来的消息："+line);
            }
        } catch (IOException e) {
            throw new RuntimeException(e);
        }

    }
}
